package com.tencent.sr.iris.activity.service.util;

import cn.hutool.core.lang.UUID;
import com.tencent.sr.iris.activity.dependency.IDCDependency;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class IdCreateorUtil {

    @Resource
    private IDCDependency iDCDependency;


    /**
     * 获取分布式id
     *
     * @return
     */
    public String genId() {
        String id;
        try {
            id = String.valueOf(iDCDependency.genId());
        } catch (Exception e) {
            log.error("IdCreatorUtil.genId 生成分布式id异常，默认使用uuid");
            id = UUID.randomUUID().toString().replace("-", "");
        }
        return id;
    }

}
